package com.careersersystem.struts.action.util;

import java.util.List;



public class PageManage {
	public int getBookTotalCount(List result){
		Integer a = (Integer) result.size();
		return a;
	}
	public int getTotalPage(int pageSize, List result){
		int totalCount = getBookTotalCount(result);
		int totalPageCount = ((totalCount + pageSize) -1 )/pageSize;
		return totalPageCount;
	}
	
	public List findPagedAll(int currentPage, int pageSize, List result){
		
			if (currentPage == 0){
				currentPage = 1;
			}
			List resultPage = result.subList((currentPage - 1) * pageSize, pageSize);
			return resultPage;
			/**if (instance.getTitle()!= null){
				example.excludeProperty("title");
			}
			criteria.add(example);
			if(instance.getTitle()!= null){
				criteria.add(Restrictions.ilike("title",instance.getTitle(),MatchMode.ANYWHERE));
			}
			criteria.setFirstResult((currentPage - 1) * pageSize);
			criteria.setMaxResults(pageSize);
			return criteria.list();**/
		
	}
   
}
